/**
 * 
 */
package test.gm

import junit.framework.TestCase
import org.juiceshop.gm.*

/**
 * @author jst
 *
 */
public class ChordTest extends TestCase{
	
	static NoteFactory nf = new NoteFactory()
	static C = nf.note(60)
	static E = nf.note(64)
	static G = nf.note(67)
	static A = nf.note(69)

	void testAsList() {
		Chord c = C%E%G
		assertTrue ([C,E,G]==c.asList())
	}
	
	void testAdd() {
		Chord c
		c = C[1,-1]
		assertEquals 3, c.size()
		assertEquals 60,c[0].pitch
		assertEquals 62,c[1].pitch
		assertEquals 59,c[2].pitch
	}
	
	void testChordPattern() {
		Chord c
		c = C.maj
		assertEquals 3,c.size()
		assertEquals 60, c[0].pitch
		c = C.min
        assertEquals 3,c.size()
        assertEquals 60, c[0].pitch
		c = A.dim
        assertEquals 3,c.size()
        assertEquals 69, c[0].pitch
	}
	
	void testTranspose() {
		Chord c1 = C.maj
		Chord c2 = c1.transpose(5)
		assertEquals c1[0].pitch+5, c2[0].pitch
        assertEquals c1[1].pitch+5, c2[1].pitch
        assertEquals c1[2].pitch+5, c2[2].pitch
	}
}
